<template>
  <theme-nav
    class="theme-nav transDot3"
    :class="{ navScroll: scrollDirection }"
  ></theme-nav>

  <div class="content-wrapper">
    <router-view class="content-main"></router-view>

    <div class="help-card transDot3" :class="{ navScroll: scrollDirection }">
      <div class="ad-one">
        <ad-one></ad-one>
      </div>
      <div class="ad-two">
        <ad-two></ad-two>
      </div>
      <authority-card class="authority"></authority-card>
    </div>
  </div>
</template>

<script lang="ts" setup>
import throttle from 'lodash/throttle'

import ThemeNav from '@/components/ThemeNav.vue'

import AuthorityCard from '@/components/HelpCard/AuthorityCard.vue'
import AdOne from '@/components/HelpCard/AdOne.vue'
import AdTwo from '@/components/HelpCard/AdTwo.vue'
import { ref, onMounted } from 'vue'

let scrollDirection = ref(false)

onMounted(() => {
  let beforeY = 0
  document.addEventListener(
    'scroll',
    throttle(() => {
      if (window.scrollY - beforeY > 0) {
        scrollDirection.value = true
      } else {
        scrollDirection.value = false
      }
      beforeY = window.scrollY
    }, 200)
  )
})
</script>

<style scoped lang="scss">
@import 'style/config';
$w: $iw;
$w1: $iwp1;
$w2: $iwp2;

.nav-bg {
  position: fixed;
  z-index: 8888;
  top: 0;
  width: 100vw;
  height: 130px;
  background-color: var(--bgColor);
  transition: 0.3s;
}

.theme-nav {
  --themeNavHeight: 60px;
  --themeNavWidth: $w;
  z-index: 8888;
  position: fixed;
  top: calc($th + 10px);
  left: 0;
  right: 0;
  margin: 0 auto;
}

.content-wrapper {
  margin: 140px auto 0;
  display: flex;
  justify-content: space-between;
  width: $w;

  .content-main {
    width: $iwp1;
  }

  .help-card {
    position: fixed;
    right: calc((100% - $iw) / 2);
    width: $iwp2;

    .ad-one {
      width: $iwp2;
    }

    .ad-two {
      margin-top: 10px;
      width: $iwp2;
    }

    .authority {
      --authorityCardWidth: $iwp2;
    }
  }
}
</style>
